#include "socketconnection.h"

SocketConnection::SocketConnection()
{
    socket = new QTcpSocket(this);
    connect(this->socket, SIGNAL(readyRead()), this, SLOT(pacoteNovo()));
    connect(this->socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(erro()));
}

void SocketConnection::pacoteNovo()
{
    QDataStream in(this->socket);
    in.setVersion(QDataStream::Qt_4_0);
    QString text;
    in >> text;
    emit this->textoRecebido(text);
}

void SocketConnection::erro()
{
    qDebug () << "deu merda";
}
